package org.misalen.web.admin.util;

/**
 * server自定义响应结构
 */
public class ServerResult {

	private boolean success;

	private String message;

	private Object data;

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	private ServerResult() {
	}

	private ServerResult(Boolean success, String msg, Object data) {
		this.success = success;
		this.message = msg;
		this.data = data;
	}

	/**
	 * 错误
	 * 
	 * @param code
	 * @return
	 */
	public static ServerResult error(String msg) {
		return new ServerResult(false, msg, null);
	}

	/**
	 * 成功
	 * 
	 * @param data
	 * @return
	 */
	public static ServerResult ok(Object data) {
		return new ServerResult(true, null, data);
	}

	/**
	 * 成功
	 * 
	 * @return
	 */
	public static ServerResult ok() {
		return new ServerResult(true, null, null);
	}

}
